package com.chixing.entity.MongDB;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedDate;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.annotation.Transient;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;


@Getter
@Setter
@Document(collection = "posts")
public class Post {
    @Id
    String id;
    Long userId;
    String content;
    String userName;
    LocalDateTime createTime;

    Long hotelId;       // 主楼所属酒店
    Long orderId;       // 主楼所属订单
    Double rating;      // 主楼评分

    Integer isDeleted;
    String officialReply;            // 商家/平台回复
    LocalDateTime officialReplyTime; // 商家回复时间

    // ---------- 非持久化字段，用于返回前端树形楼中楼 ----------
    @Transient
    List<Reply> replies = new ArrayList<>();

    public Post() {
    }

    public Post(String id, Long userId, String content, String userName, LocalDateTime createTime, Long hotelId, Long orderId, Double rating, Integer isDeleted, String officialReply, LocalDateTime officialReplyTime, List<Reply> replies) {
        this.id = id;
        this.userId = userId;
        this.content = content;
        this.userName = userName;
        this.createTime = createTime;
        this.hotelId = hotelId;
        this.orderId = orderId;
        this.rating = rating;
        this.isDeleted = isDeleted;
        this.officialReply = officialReply;
        this.officialReplyTime = officialReplyTime;
        this.replies = replies;
    }
}
